
int  check(int check[1000][1000], int x, int y, int cx, int cy)
{	
	int k1 = x;
	while (k1 < cx)
	{
		if ( check[k1][cy] == 0 )
			return 0;
		k1 = k1 + 1;
	}

	int k2 = x;
	while (k2 < cx+1)
	{
		if ( check[k2][y-1] == 1 )
			return 0;
		k2 = k2 + 1;
	}

	int k3 = x+1;
	while (k3 < cx)
	{
		if ( check[k3][y+1] == 1 )
			return 0;
		k3= k3 + 1 ;
	}

	int k4 = x;
	while (k4 < cx+1)
	{
		if ( check[k4][cy +1] == 1 )
			return 0;
		k4 = k4 + 1;
	}

	int k5 = x+1;
	while (k5 < cx)
	{
		if ( check[k5][cy - 1] == 1 )
			return 0;
		k5 = k5 + 1;
	}

	int k6 = y;
	while (k6 < cy)
	{
		if ( check[cx][k6] == 0 )
			return 0;
		k6 = k6 + 1;
	}
	int k7 = y;
	while (k7 < cy+1)
	{
		if ( check[x-1][k7] == 1 )
			return 0;
		k7 = k7 + 1;
	}
	int k8 = y+1;
	while (k8 < cy)
	{
		if ( check[x +1][k8] == 1 )
			return 0;
		k8 = k8 + 1;
	}
	int k9 = y;
	while (k9 < cy+1)
	{
		if ( check[cx +1][k9] == 1 )
			return 0;
		k9 = k9 + 1;
	}
	int k10 = y+1;
	while (k10 < cy)
	{
		if ( check[cx -1][k10] == 1 )
			return 0;
		k10 = k10 + 1;
	}
	return 1;
}
int test_main(int map[1000][1000]) {
	int result = 0;
	int i = 0;
	while (i < 1000) {
		int j = 0;
		while (j < 1000) {
			if (map[i][j] ==1 && map[i][j+1] ==1 && map[i][j+2] ==1 && map[i+1][j] == 1 && map[i+2][j] == 1)
			{
				int cx = 0;
				int cy = 0;
				int a = i;
				while (a < 1000)
				{
					if (map[a+1][j] == 0) 
					{ 
						cx = a;
						break;
					}
					a = a + 1;
				}
				int b = j;
				while (b < 1000)
				{
					if (map[i][b+1] == 0)
					{
						cy = b;
						break;
					}
					b = b + 1;
				}
				if (check (map, i, j, cx, cy) == 1) result ++;
			}
			j = j+1;
		}
		i = i+1;
	}
	return result;
}



